<!doctype html>
<!--[if IE 7 ]>    <html lang="en" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]>    <html lang="en" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]>    <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<head>
	<meta charset="UTF-8">
	<title>Login | UT Safety</title>
	<meta name="description" content="">
	<meta name="author" content="">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	
	<link rel="shortcut icon" href="/favicon.ico">
	<link rel="apple-touch-icon" href="/apple-touch-icon.png">
	
	<!-- CSS Styles -->

	
	<!-- Google WebFonts -->
	<link href='http://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css'>
	
	<script src="/Assets/js/libs/modernizr-1.7.min.js"></script>
</head>
<body class="login">
	<section role="main">
	
		<a href=""></a>
		<h1>University of Texas System Safety Analysis Report</h1>
		<!-- Login box -->
		<article id="login-box">
		
			<div class="article-container">
			    <p>Enter your login credentials below.</p>
				<!-- Notification -->
				<div id="results" class="">
				
				
				</div>
				<!-- /Notification -->
			
				<form action="/Login/Do" id="loginform">
					<fieldset>
						<dl>
							<dt>
								<label>Email</label>
							</dt>
							<dd>
								<input type="text" name="email" id="email" class="large">
							</dd>
							<dt>
								<label>Password</label>
							</dt>
							<dd>
								<input type="password" name="password" id="password" class="large">
							</dd>
							
						</dl>
					</fieldset>
					<a href="" class="button right" onclick="DoLogin(); return false;">Log in</a>
				</form>
			
			</div>
		
		</article>
		<!-- /Login box -->
		<ul class="login-links">
			<%--<li><a href="#">Lost password?</a></li>--%>
			
		</ul>
		
	</section>

	<!-- JS Libs at the end for faster loading -->
	<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
	<script>	    !window.jQuery && document.write(unescape('%3Cscript src="js/jquery/jquery-1.5.1.min.js"%3E%3C/script%3E'))</script>
	<script src="/Assets/js/libs/selectivizr.js"></script>
	<script src="/Assets/js/jquery/jquery.tipsy.js"></script>
	<script src="/Assets/js/login.js"></script>
	  <script type="text/javascript">

	      $(document).ready(function () {
	          $('#password').bind('keypress', function (e) {
	              var code = (e.keyCode ? e.keyCode : e.which);
	              if (code == 13) { //Enter keycode
	                  DoLogin();
	              }

	          });

	      });
	      function DoLogin() {
	          var form = $("#loginform");
	          $("#results").addClass("notification");
	          if ($("#email").val() == "" || $("#password").val() == "") {
	              $("#results").html("Please complete all fields.");
	              $("#results").addClass("error");

	              return false;
	          }


	          else {
	              $("#results").html("Authenticating...");
	              $("#results").addClass("information");

	              $.ajax({
	                  type: "POST",
	                  url: form.attr('action'),
	                  data: form.serialize(),
	                  error: function (xhr, status, error) {
	                  },
	                  success: function (response) {
	                      $("#results").removeClass("information");
	                      if (response != null) {
	                          if (!response.Successful) {
	                              $("#results").html("Invalid credentials.");
	                              $("#results").addClass("error");
	                              return false;
	                          }
	                          else {

	                              $("#results").html("Success!");
	                              $("#results").addClass("success");
	                              if (window.location.search != "") {
	                                  window.location = window.location.search.substr(3);
	                              }
	                              else {
	                                  window.location = "/index";
	                              }
	                              return true;
	                          }
	                      }
	                  }
	              });
	          }
	          return false;
	      }
    </script>
</body>
</html>